import {UtilFile} from "./UtilFile";

const moment = require('moment');

export class Util {

    static dateFormat = 'YYYY-MM-DD HH:mm:ss';

    static now(){
        return moment().format(Util.dateFormat);
    }

    static isDev(){
        let env = process.env.NODE_ENV || 'production';
        env = env.toLowerCase();
        return env == 'dev';
    }



    static readI18nResFromDir(dir){
        const ret = {};
        UtilFile.listFile(dir,(file)=>{
            const content = require(file.fullPath);
            ret[file.name] = content;
        });
        return ret;
    }

    static async sleep(time){
        return new Promise((yes)=>{
            setTimeout(()=>yes(),time);
        });
    }


}